<?php
/*********************************************************************************
easyZenImport v.8b - Easy, Ajax Driven Importing Front-End For EasyPopulate 
Copyright (C) 11-02-06 Nick Van Dorsten
Author: Nick Van Dorsten <nickvd@gmail.com>

This library is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2.1 of the License, or (at your option) any later
version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
*********************************************************************************/
if (!empty($_POST)) {
   require_once('easyimport.cfg.php');
   updateQueueFile(formatProductArray($_POST));
   $id = count(readQueueFile())-1;
   $imageName = (!empty($up->imageName))?DIR_WS_CATALOG_IMAGES.'thumb/'.$up->imageName:'';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>easyZenImport</title>
<style type="text/css">
body#ajax {margin:0;padding:0;font-family: arial,sans-serif;background:transparent;overflow:hidden;}
body#ajax label {margin: 0;display: block;width: 7em;text-align: right;float: left;margin-right: .5em;}
body#ajax input {width: 20em;margin: .25em 0;}
body#ajax input.submit {width:12em;margin:.5em auto;display:block;}
</style>
<script type="text/javascript" src="jquery_.js"></script>
<script type="text/javascript">
//<![CDATA[
<?php if (!empty($_POST)) {echo "window.parent.addToQueue('{$imageName}',{$id});";} ?>
function upload() {
   var p = window.parent.document;
   window.parent.loading.toggle();
   pxfer = p.getElementById('formFields');
   try{$('#hiddenForm').children().remove();}catch(e){};
   $(pxfer).find('.xfer').clone().appendTo('#hiddenForm');
   $('#desc').html(p.getElementById('desc').value);
   $('#cat').attr('value',p.getElementById('cat').value);
   return true;
}
//]]>
</script>
</head><body id="ajax"><form name="iform" id="iform" action="ajaxupload.php" method="post" onsubmit="return upload();" enctype="multipart/form-data"><label for="file">Image Upload:</label><input type="file" name="fileupload"/><input type="submit" class="submit" value="Add Product To Queue" /><div id="hiddenForm"></div></form></body></html>